package com.imti.mall.product.mapper;

import com.imti.mall.model.pms.pojo.PmsProductLadder;
import org.apache.ibatis.jdbc.SQL;

public class PmsProductLadderDynaSqlProvider {

    /**
     * 根据梯价表id修改梯价表
     * @param pmsProductLadder
     * @return
     */
    public String updatePmsProductLadder(final PmsProductLadder pmsProductLadder){
        return new SQL(){
            {
                UPDATE(" pms_product_full_reduction ");
                if(pmsProductLadder!=null){
                    if (pmsProductLadder.getProductId() != null) {
                        SET("  product_id=#{productId}");
                    }
                    if (pmsProductLadder.getCount() != null) {
                        SET("  count=#{count}");
                    }
                    if (pmsProductLadder.getDiscount() != null) {
                        SET("   discount=#{discount}");
                    }
                    if (pmsProductLadder.getPrice() != null) {
                        SET("  price=#{price}");
                    }
                }
                WHERE(" id=#{id} ");
            }

        }.toString();
    }
}
